<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <title>注册页面</title>
    <link rel="shortcut icon" type="image/x-icon" href="https://res.wx.qq.com/a/wx_fed/assets/res/NTI4MWU5.ico">
    <link href="css/bootstrap.min.css" rel="stylesheet">

</head>

<body>
    <div class="row" style="margin: 20px 20px 10px 20px;">
        <div class="form-group" style="height: 34px;">
            <img src="" id="codeImg" onclick="refresh()" style="margin-right: 5px;float: left;" />
            <span class="input-group">
                <input type="text" class="form-control" id="code" placeholder="图片验证码" />
                <span class="input-group-btn">
                    <input type="button" class="btn btn-info" style="width: 100px;" onclick="mySendCode()" value="获取验证码" />
                </span>
            </span>
        </div>
    </div>
    <script src="js/jquery-3.2.1.min.js"></script>

    <script src="js/layer.js"></script>

    <script>
        function errInfo(res, b) {
            if (res.data.errno == 1 || b) {
                parent.layer.open({
                    title: '提示',
                    content: res.data.errmsg,
                    btn: ['我知道了']
                });
            }
        }
    </script>

    <!-- 请求 -->
    <script src="js/axios.min.js"></script>
    <script src="js/request.js"></script>
    <script>
        refresh();
        //刷新验证码
        function refresh() {
            $("#codeImg").prop("src", axios.defaults.baseURL + "/user/getCode?phone=" + parent.vm.user.phone + "&time=" + new Date().getTime());
        }
        function mySendCode() {
            getPhoneCode(parent.vm.user.phone, $("#code").val()).then(res => {
                errInfo(res);
                parent.vm.time = 60;
                parent.vm.countDown();
                if (res.data.errno == 0) {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            })
        }

    </script>
</body>

</html>